package cn.easier.activity.console.service.impl;

import cn.easier.activity.console.repository.ActivityAdvancedSettingRepository;
import cn.easier.activity.console.service.ActivityAdvancedSettingService;
import cn.easier.activity.web.entity.ActivityAdvancedSetting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 高级设置serviceImpl
 */
@Service
@Transactional
public class ActivityAdvancedSettingServiceImpl implements ActivityAdvancedSettingService {

    @Autowired
    ActivityAdvancedSettingRepository activityAdvancedSettingRepository;

    @Override
    public ActivityAdvancedSetting findOne(Integer scene, Integer activityInfoId) {
        return activityAdvancedSettingRepository.findActivityAdvancedSettingBySceneAndActivityInfoId(scene, activityInfoId);
    }

    @Override
    public List<ActivityAdvancedSetting> findByActivityInfoId(Integer activityInfoId) {
        return activityAdvancedSettingRepository.findActivityAdvancedSettingsByActivityInfoId(activityInfoId);
    }

    @Override
    public ActivityAdvancedSetting save(ActivityAdvancedSetting activityAdvancedSetting) {
        return activityAdvancedSettingRepository.save(activityAdvancedSetting);
    }

    @Override
    public ActivityAdvancedSetting update(ActivityAdvancedSetting activityAdvancedSetting) {
        return activityAdvancedSettingRepository.saveAndFlush(activityAdvancedSetting);
    }

    @Override
    public int delete(Integer scene, Integer activityInfoId) {
        return activityAdvancedSettingRepository.deleteFlag(scene, activityInfoId);
    }
}
